<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>登录界面</title>
</head>
<body onload="check_result()">
<form th:action="@{/login}" method="post">
    用户名：<input type="text" th:name="username"><br>
    密码：<input type="password" th:name="password"><br>
    <input type="submit" value="登录">
    <a th:href="@{'http://localhost:8001/register'}" th:style="'text-decoration:none;'"><input type="button" value="注册页面"></a>
</form>
<!--待完善-->
<form th:action="@{/logout}" method="post">
    <input type="submit" value="注销">
</form>
<br/>
</body>
<script type="text/javascript" th:inline="javascript">
    function check_result(){
        var message = [[${result}]];
        if(message == null){
            return;
        }
        var result = eval("(" + message + ")");
        if(result.code=="0"){
            alert("登录成功！");
            window.location.href="http://localhost:8002/board";
        }
        else
            alert(result.msg);
    }
</script>
</html>